package com.chj.chuji.tijie14;

import java.util.ArrayList;

//https://blog.csdn.net/qq_43857314/article/details/107805452
public class BlueMage {

	public static class ArrList {
		public ArrayList<Integer> arr;

		public ArrList() {
			arr = new ArrayList<Integer>();
		}
	}

	public static void dfs(int u, int fa) {
		dp[u][1] = 1;
		sz[u] = 1;
		for (int e : v[u].arr) {
			if (e == fa)
				continue;
			dfs(e, u);
			int sum = 0;
			/// 连边
			for (int i = 1; i <= Math.min(sz[u], m); i++) {
				for (int k = 1; k <= Math.min(sz[e], m); k++) {
					if (i + k <= m) {
						tmp[i + k] += (dp[u][i] * dp[e][k]) % mod;
						tmp[i + k] %= mod;
					}
				}
			}
			/// 不连边
			for (int i = 1; i <= Math.min(m, sz[e]); i++) {
				sum = (sum + dp[e][i]) % mod;
			}

			for (int i = 1; i <= m; i++) {
				dp[u][i] = (tmp[i] + sum * dp[u][i]) % mod;
				tmp[i] = 0;
			}
			sz[u] += sz[e];
		}
	}

	public static int n;
	public static int m;
	public static int p;
	public static int[][] dp = new int[2005][2005];
	public static ArrList[] v = new ArrList[2005];
	// vector<int>v[maxn];
	public static final int mod = 998244353;
	public static int[] sz = new int[2005];
	public static int[] tmp = new int[2005];

	public static void main(String[] args) {
		n = 5;
		m = 2;
//		1 2
//		1 3
//		2 4
//		2 5

//      v[x].push_back(y);
//      v[y].push_back(x);
		ArrList arr02 = new ArrList();
		arr02.arr.add(2);
		arr02.arr.add(3);
		v[1] = arr02;

		ArrList arr03 = new ArrList();
		arr03.arr.add(4);
		arr03.arr.add(5);
		arr03.arr.add(1);
		v[2] = arr03;

		ArrList arr04 = new ArrList();
		arr04.arr.add(1);
		v[3] = arr04;

		ArrList arr05 = new ArrList();
		arr05.arr.add(2);
		v[4] = arr05;

		ArrList arr06 = new ArrList();
		arr06.arr.add(2);
		v[5] = arr06;

		dfs(1, 1);
		int ans = 0;
		for (int k = 1; k <= m; k++) {
			ans = (ans + dp[1][k]) % mod;
		}
		System.out.println(ans);
	}
}

///*** keep hungry and calm CoolGuang!***/
//ll n,m,p;
//ll dp[2005][2005];
//vector<int>v[maxn];
//int sz[maxn];
//ll tmp[maxn];
//void dfs(int u,int fa){
//    dp[u][1] = 1;
//    sz[u] = 1;
//    for(int e:v[u]){
//        if(e == fa) continue;
//        dfs(e,u);
//        ll sum = 0;
//        ///连边
//        for(int i=1;i<=min(sz[u]*1ll,m);i++){
//            for(int k=1;k<=min(sz[e]*1ll,m);k++){
//                if(i+k<=m){
//                    tmp[i+k] += (dp[u][i]*dp[e][k])%mod;
//                    tmp[i+k] %=mod;
//                }
//            }
//        }
//        ///不连边
//        for(int i=1;i<=min(m,sz[e]*1ll);i++) sum = (sum + dp[e][i])%mod;
//        for(int i=1;i<=m;i++){
//            dp[u][i] = (tmp[i] + sum*dp[u][i])%mod;
//            tmp[i] = 0;
//        }
//        sz[u] += sz[e];
//    }
//}
//int main(){
//    read(n);read(m);
//    for(int i=1;i<=n-1;i++){
//        ll x,y;read(x);read(y);
//        v[x].push_back(y);
//        v[y].push_back(x);
//    }
//    dfs(1,1);
//    ll ans = 0;
//    for(int k=1;k<=m;k++) ans = (ans + dp[1][k])%mod;
//    printf("%lld\n",ans);
//    return 0;
//}
///***
//3 3
//1 2
//1 3
//***/
